package com.ruoyi.web.controller.yf;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yf.domain.YfDistrictStatistical;
import com.ruoyi.yf.service.IYfDistrictStatisticalService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地区医废每日统计Controller
 * 
 * @author XiaoYi...
 * @date 2020-09-29
 * be4dbf60-ce2c-430c-afa3-70975d6aad21
 */
@Controller
@RequestMapping("/yf/statistical")
public class YfDistrictStatisticalController extends BaseController
{
    private String prefix = "yf/statistical";

    @Autowired
    private IYfDistrictStatisticalService yfDistrictStatisticalService;

    @RequiresPermissions("yf:statistical:view")
    @GetMapping()
    public String statistical()
    {
        return prefix + "/statistical";
    }

    /**
     * 查询地区医废每日统计列表
     * ebb18825-138d-42e8-b9b6-ebc18f968e36
     */
    @RequiresPermissions("yf:statistical:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YfDistrictStatistical yfDistrictStatistical)
    {
        startPage();
        List<YfDistrictStatistical> list = yfDistrictStatisticalService.selectYfDistrictStatisticalList(yfDistrictStatistical);
        return getDataTable(list);
    }

    /**
     * 导出地区医废每日统计列表
     * f64cd98a-9dc4-4a7f-a23f-ea4a21b42b50
     */
    @RequiresPermissions("yf:statistical:export")
    @Log(title = "地区医废每日统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YfDistrictStatistical yfDistrictStatistical)
    {
        List<YfDistrictStatistical> list = yfDistrictStatisticalService.selectYfDistrictStatisticalList(yfDistrictStatistical);
        ExcelUtil<YfDistrictStatistical> util = new ExcelUtil<YfDistrictStatistical>(YfDistrictStatistical.class);
        return util.exportExcel(list, "statistical");
    }

    /**
     * 新增地区医废每日统计
     * d274e9fd-1d8f-4c48-9ea5-d5a9a4bd1916
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存地区医废每日统计
     * 4a4ec559-24c6-455b-a974-0ac8d596e01f
     */
    @RequiresPermissions("yf:statistical:add")
    @Log(title = "地区医废每日统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YfDistrictStatistical yfDistrictStatistical)
    {
        return toAjax(yfDistrictStatisticalService.insertYfDistrictStatistical(yfDistrictStatistical));
    }

    /**
     * 修改地区医废每日统计
     * a60eddf0-de67-40f7-bb51-3770ff346d5a
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        YfDistrictStatistical yfDistrictStatistical = yfDistrictStatisticalService.selectYfDistrictStatisticalById(id);
        mmap.put("yfDistrictStatistical", yfDistrictStatistical);
        return prefix + "/edit";
    }

    /**
     * 修改保存地区医废每日统计
     * 045436e1-4943-479e-9f5b-46e38ced8a60
     */
    @RequiresPermissions("yf:statistical:edit")
    @Log(title = "地区医废每日统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YfDistrictStatistical yfDistrictStatistical)
    {
        return toAjax(yfDistrictStatisticalService.updateYfDistrictStatistical(yfDistrictStatistical));
    }

    /**
     * 删除地区医废每日统计
     * 85983262-3454-4c50-9075-348a92b90798
     */
    @RequiresPermissions("yf:statistical:remove")
    @Log(title = "地区医废每日统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yfDistrictStatisticalService.deleteYfDistrictStatisticalByIds(ids));
    }
}
